import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vite.dev/config/

export default defineConfig(({ mode }) => {
  const env = loadEnv(mode, process.cwd());

  const baseURL = env.VITE_APP_BASE_API;
  console.log(mode)
  console.log(baseURL)
  console.log(env)
  return {
    plugins: [
      vue(),
      // vueDevTools(),
    ],
    resolve: {
      alias: {
        // '~': path.resolve(__dirname, './'),
        '@': '/src'
      },
      extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
    },
    server: {
      host: '0.0.0.0',
      port: 8088,
      open: false,
      proxy: {
        [env.VITE_APP_BASE_API]: { // /webapi
          // target: 'http://117.72.48.104:8091',
          target: 'http://127.0.0.1:8091',
          changeOrigin: true,
          pathRewrite: { // 后台访问serverPath
            [env.VITE_APP_BASE_API]: env.VITE_APP_BASE_API
          }
        }
      }
    }
  }
})


